//
//  DNLeftDrawerTableViewController.m
//  DanoneEA
//
//  Created by Senela on 16/9/20.
//  Copyright © 2016年 翔傲科技. All rights reserved.
//

#import "DNLeftDrawerTableVC.h" 
#import "DNAboutStudyVC.h"
#import "DNNotificationsVC.h"
#import "DNHelpVC.h"
#import "DNChangeLanguageVC.h"

@interface DNLeftDrawerTableVC ()<UITableViewDelegate, UITableViewDataSource>

@end

@implementation DNLeftDrawerTableVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationController.navigationBar.hidden = YES;
    _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
    
    [self.tableView setDelegate:self];
    [self.tableView setDataSource:self];
    [self.view addSubview:self.tableView];
    
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.tableView setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
    [self.tableView setBackgroundColor:[UIColor darkGrayColor]];
    self.tableView.tableFooterView = [[UIView alloc] init];
    
    [self.view setBackgroundColor:[UIColor darkGrayColor]];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source 
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    cell.contentView.backgroundColor = [UIColor darkGrayColor];
    cell.textLabel.textColor = [UIColor whiteColor];
    
    if(indexPath.row == 0)
    {
        [cell.textLabel setText:DNNSLocalizedString(@"BtnTitle_AboutStudy",@"")];
    }
    else if(indexPath.row == 1)
    {
        [cell.textLabel setText:DNNSLocalizedString(@"BtnTitle_Notifications",@"")];
    }
    else if(indexPath.row == 2)
    {
        [cell.textLabel setText:DNNSLocalizedString(@"BtnTitle_Help",@"")];
    }
    else if(indexPath.row == 3)
    {
        [cell.textLabel setText:DNNSLocalizedString(@"BtnTitle_LanguageChange",@"")];
    }

    
    return cell;
}




-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40.0;
}


#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    [self.mm_drawerController  setCenterViewController:appDelegate.tabBarVC
     withCloseAnimation:YES  completion:nil];
    
    UIViewController *VC;
    if(indexPath.row == 0)
        VC = [[DNAboutStudyVC alloc] init];
    else if(indexPath.row == 1)
        VC = [[DNNotificationsVC alloc] init];
    else if(indexPath.row == 2)
        VC = [[DNHelpVC alloc] init];
    else if(indexPath.row == 3)
        VC = [[DNChangeLanguageVC alloc] init];
    
    
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:VC];
    [self.mm_drawerController.centerViewController presentViewController:navController animated:YES completion:nil];
}


@end
